Hi there,
taking the 6502 simulator tutorials, and after ex02 it tells me to convert the program into machine code myself and then compare it to what 6502 simulator outputs, but i'm not sure how to see what it does output.
anywhay, here's the code:
i can find the opcodes with the help of this text (thanks B00daw), but other than that, i'm not too sure i can make sense of most of it besides the addresses. well not enough to convert it to machine code.
what do i do? and how do i check it on 6502 simulator?
taking the 6502 simulator tutorials, and after ex02 it tells me to convert the program into machine code myself and then compare it to what 6502 simulator outputs, but i'm not sure how to see what it does output.
anywhay, here's the code:
Code:
; Program to add two 16 bit numbers
; The numbers being added are $0194 and $01BA
; Add1601.65s
.ORG $0200 ; store machine code starting here
LDA #$94 ; Store least significant end of number 1 in first
STA no1+0 ; byte labelled no1
LDA #$01 ; Store MSB end of number 1 in next byte
STA no1+1 ; after the one labeled no1
LDA #$BA ; Store littel end of number 2 in first
STA no2+0 ; byte labelled no2
LDA #$01 ; Store MSB of number 2 in the next byte after
STA no2+1 ; the one labeled no2
CLC ; Clear the carry flag
LDA no1+0 ; load LSB of number 1 into accumulator register
ADC no2+0 ; Add with carry the little end of number 2
STA res+0 ; Store the LSB of the result in a byte labelled res
LDA no1+1 ; Load big end of number 1 into accumulator
ADC no2+1 ; Add with carry the big end of number 2
STA res+1 ; Store the MSB of the result into the byte
; following the one labeled res
BRK ; stop running the program
no1: .DW $0000 ; The .DW directive instructs the assembler to
; reserver one word(16 bits)
no2: .DW $0000 ; of memory, and allows the programmer to
; refer to it by using a label
res: .DW $0000 ; This is how you declare variables
; The numbers being added are $0194 and $01BA
; Add1601.65s
.ORG $0200 ; store machine code starting here
LDA #$94 ; Store least significant end of number 1 in first
STA no1+0 ; byte labelled no1
LDA #$01 ; Store MSB end of number 1 in next byte
STA no1+1 ; after the one labeled no1
LDA #$BA ; Store littel end of number 2 in first
STA no2+0 ; byte labelled no2
LDA #$01 ; Store MSB of number 2 in the next byte after
STA no2+1 ; the one labeled no2
CLC ; Clear the carry flag
LDA no1+0 ; load LSB of number 1 into accumulator register
ADC no2+0 ; Add with carry the little end of number 2
STA res+0 ; Store the LSB of the result in a byte labelled res
LDA no1+1 ; Load big end of number 1 into accumulator
ADC no2+1 ; Add with carry the big end of number 2
STA res+1 ; Store the MSB of the result into the byte
; following the one labeled res
BRK ; stop running the program
no1: .DW $0000 ; The .DW directive instructs the assembler to
; reserver one word(16 bits)
no2: .DW $0000 ; of memory, and allows the programmer to
; refer to it by using a label
res: .DW $0000 ; This is how you declare variables
i can find the opcodes with the help of this text (thanks B00daw), but other than that, i'm not too sure i can make sense of most of it besides the addresses. well not enough to convert it to machine code.
what do i do? and how do i check it on 6502 simulator?