Videopac / Odyssey2 forum
September 23, 2021, 10:31:11 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: If you have some news and you want it to be shown here, pm Janzl!
   Home   Help Login Register links  
Pages: [1]   Go Down
Author Topic: 8048 tips and tricks  (Read 254 times)
Trying to get the cartridge in...
Posts: 47

« on: April 16, 2021, 07:07:04 PM »

Hey all!

Working on a game (to be announced) that needs to have an 8-bit value signed extended into a 16-bit value. It's adapted from the 6502 but works just as nice. Given an 8-bit signed number, here's a snippet:

mov a,r0      ; signed 8-bit value
rlc a          ; sign bit in carry
mov r2,a      ; save     
cpl a
adc r2
cpl a          ; subtract from itself: either 0 or ff
mov r2,a      ; save

And yes, you could just do a sign check and clr / set but this is nicer IMO  Tongue
Pages: [1]   Go Up
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!